﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;

namespace Clandestine
{
    public static class Camera
    {
        public static PointF Position;
        public static float Zoom = 1f;
        public static float Angle = 0f;

        private static object LockBlob = new object();

        public static void UpdateScrolling(Point focusPoint)
        {
            // scroll dat bitch
            int borderWidth = 150;
            if (focusPoint.X <= Camera.Position.X + borderWidth) // LEFT
                Camera.Position.X -= (Camera.Position.X + borderWidth) - focusPoint.X;
            if (focusPoint.X >= (Camera.Position.X + Graphics.ScreenWidth - borderWidth)) // RIGHT
                Camera.Position.X += focusPoint.X - (Camera.Position.X + Graphics.ScreenWidth - borderWidth);
            if (focusPoint.Y <= Camera.Position.Y + borderWidth) // TOP
                Camera.Position.Y -= (Camera.Position.Y + borderWidth) - focusPoint.Y;
            if (focusPoint.Y >= (Camera.Position.Y + Graphics.ScreenHeight - borderWidth)) // BOTTOM
                Camera.Position.Y += focusPoint.Y - (Camera.Position.Y + Graphics.ScreenHeight - borderWidth);

            // Make sure we don't go over map boundaries
            if (Camera.Position.X < 0)
                Camera.Position.X = 0;
            if ((Camera.Position.X + Graphics.ScreenWidth) > (WorldMap.Level.Width * WorldMap.Level.GridSize))
                Camera.Position.X = (WorldMap.Level.Width * WorldMap.Level.GridSize) - Graphics.ScreenWidth;
            if (Camera.Position.Y < 0)
                Camera.Position.Y = 0;
            if ((Camera.Position.Y + Graphics.ScreenHeight) > (WorldMap.Level.Height * WorldMap.Level.GridSize))
                Camera.Position.Y = (WorldMap.Level.Height * WorldMap.Level.GridSize) - Graphics.ScreenHeight;
        }
    }
}
